package com.xpgk.mvc.baseInfoSet;

import java.util.List;

import com.jfinal.log.Log;
import com.xpgk.dto.RenderBean;
import com.xpgk.dto.ZtreeNode;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.codeSet.Code;

public class BaseInfoController extends BaseController{
	
	@SuppressWarnings("unused")
	private static final Log log = Log.getLog(BaseInfoController.class);
	
	private BaseInfoSetService baseInfoSetService;
	
	public void index() {
		render("baseInfo.html");
	}
	
	/**
	 * Tree节点数据
	 */
	public void treeData() {
		List<ZtreeNode> nodeList = baseInfoSetService.childNodeData(getCxt(), ids);
		renderJson(nodeList);
	}
	
	/**
	 * 跳转至添加
	 */
	public void toAdd() {
		BaseInfoSet bis = getModel(BaseInfoSet.class);
		setAttr("baseInfoSet", bis);
		setAttr("parentInfo", BaseInfoSet.dao.findById(bis.getStr(BaseInfoSet.column_parentids)));
		render("addBaseInfo.html");
	}
	
	/**
	 * 添加
	 */
	public void addBaseInfo(){
		BaseInfoSet baseInfo = getModel(BaseInfoSet.class);
		RenderBean renderBean = baseInfoSetService.addBaseInfo(baseInfo);
		renderJson(renderBean);
		
	}
	
	/**
	 * 跳转至更新
	 */
	public void toUpdate() {
		setAttr("baseInfoSet", BaseInfoSet.dao.findById(ids));
		render("updateBaseInfo.html");
	}
	
	/**
	 * 修改
	 */
	public void upBaseInfo(){
		BaseInfoSet baseInfo = getModel(BaseInfoSet.class);
		RenderBean renderBean = baseInfoSetService.updateBaseInfo(baseInfo);
		renderJson(renderBean);
	}
	
	/**
	 * 参数列表
	 */
	public void baseInfoList() {
		String json = paging(splitPage, BaseInfoSet.sqlId_splitPageSelect, BaseInfoSet.sqlId_splitPageFrom);
		renderJson(json);
	}

}
